﻿using Microsoft.AspNetCore.Mvc;
using Newtonsoft.Json;

namespace Magic.Web.Entry;

/// <summary>
/// 代码生成器服务
/// </summary>
public class CodeGeneratorController : BaseController
{
    private readonly ICodeGeneratorService _service;
    public CodeGeneratorController(ICodeGeneratorService service)
    {
        _service = service;
    }

    [HttpGet("getDatabaseList")]
    public DatabaseListOutput GetDatabaseList()
    {
        return _service.GetDatabaseList();
    }
    [HttpPost("parseFieldData")]
    public ParseFieldDataOutput ParseFieldData(ColumnInfosByTableNameInput input)
    {
        return _service.ParseFieldData(input);
    }

    [HttpPost("checkCrudLog")]
    public dynamic CheckCrudLog(dynamic input)
    {
        return new { Id = 0 };
    }
    [HttpGet("getFileData")]
    public dynamic GetFileData(string table)
    {
        var str = "{\r\n    \"modelFile\": \"app\\\\admin\\\\model\\\\Admin.php\",\r\n    \"controllerFile\": \"app\\\\admin\\\\controller\\\\auth\\\\Admin.php\",\r\n    \"validateFile\": \"app\\\\admin\\\\validate\\\\Admin.php\",\r\n    \"controllerFileList\": {\r\n        \"app\\\\admin\\\\controller\\\\auth\\\\Admin.php\": \"app\\\\admin\\\\controller\\\\auth\\\\Admin.php\",\r\n        \"app\\\\admin\\\\controller\\\\auth\\\\AdminLog.php\": \"app\\\\admin\\\\controller\\\\auth\\\\AdminLog.php\",\r\n        \"app\\\\admin\\\\controller\\\\auth\\\\Group.php\": \"app\\\\admin\\\\controller\\\\auth\\\\Group.php\",\r\n        \"app\\\\admin\\\\controller\\\\auth\\\\Menu.php\": \"app\\\\admin\\\\controller\\\\auth\\\\Menu.php\",\r\n        \"app\\\\admin\\\\controller\\\\crud\\\\Crud.php\": \"app\\\\admin\\\\controller\\\\crud\\\\Crud.php\",\r\n        \"app\\\\admin\\\\controller\\\\crud\\\\Log.php\": \"app\\\\admin\\\\controller\\\\crud\\\\Log.php\",\r\n        \"app\\\\admin\\\\controller\\\\routine\\\\Attachment.php\": \"app\\\\admin\\\\controller\\\\routine\\\\Attachment.php\",\r\n        \"app\\\\admin\\\\controller\\\\security\\\\DataRecycle.php\": \"app\\\\admin\\\\controller\\\\security\\\\DataRecycle.php\",\r\n        \"app\\\\admin\\\\controller\\\\security\\\\DataRecycleLog.php\": \"app\\\\admin\\\\controller\\\\security\\\\DataRecycleLog.php\",\r\n        \"app\\\\admin\\\\controller\\\\security\\\\SensitiveData.php\": \"app\\\\admin\\\\controller\\\\security\\\\SensitiveData.php\",\r\n        \"app\\\\admin\\\\controller\\\\security\\\\SensitiveDataLog.php\": \"app\\\\admin\\\\controller\\\\security\\\\SensitiveDataLog.php\",\r\n        \"app\\\\admin\\\\controller\\\\user\\\\Group.php\": \"app\\\\admin\\\\controller\\\\user\\\\Group.php\",\r\n        \"app\\\\admin\\\\controller\\\\user\\\\MoneyLog.php\": \"app\\\\admin\\\\controller\\\\user\\\\MoneyLog.php\",\r\n        \"app\\\\admin\\\\controller\\\\user\\\\Rule.php\": \"app\\\\admin\\\\controller\\\\user\\\\Rule.php\",\r\n        \"app\\\\admin\\\\controller\\\\user\\\\ScoreLog.php\": \"app\\\\admin\\\\controller\\\\user\\\\ScoreLog.php\",\r\n        \"app\\\\admin\\\\controller\\\\user\\\\User.php\": \"app\\\\admin\\\\controller\\\\user\\\\User.php\"\r\n    },\r\n    \"modelFileList\": {\r\n        \"app\\\\admin\\\\model\\\\Admin.php\": \"app\\\\admin\\\\model\\\\Admin.php\",\r\n        \"app\\\\admin\\\\model\\\\AdminGroup.php\": \"app\\\\admin\\\\model\\\\AdminGroup.php\",\r\n        \"app\\\\admin\\\\model\\\\AdminLog.php\": \"app\\\\admin\\\\model\\\\AdminLog.php\",\r\n        \"app\\\\admin\\\\model\\\\Config.php\": \"app\\\\admin\\\\model\\\\Config.php\",\r\n        \"app\\\\admin\\\\model\\\\CrudLog.php\": \"app\\\\admin\\\\model\\\\CrudLog.php\",\r\n        \"app\\\\admin\\\\model\\\\DataRecycle.php\": \"app\\\\admin\\\\model\\\\DataRecycle.php\",\r\n        \"app\\\\admin\\\\model\\\\DataRecycleLog.php\": \"app\\\\admin\\\\model\\\\DataRecycleLog.php\",\r\n        \"app\\\\admin\\\\model\\\\MenuRule.php\": \"app\\\\admin\\\\model\\\\MenuRule.php\",\r\n        \"app\\\\admin\\\\model\\\\SensitiveData.php\": \"app\\\\admin\\\\model\\\\SensitiveData.php\",\r\n        \"app\\\\admin\\\\model\\\\SensitiveDataLog.php\": \"app\\\\admin\\\\model\\\\SensitiveDataLog.php\",\r\n        \"app\\\\admin\\\\model\\\\User.php\": \"app\\\\admin\\\\model\\\\User.php\",\r\n        \"app\\\\admin\\\\model\\\\UserGroup.php\": \"app\\\\admin\\\\model\\\\UserGroup.php\",\r\n        \"app\\\\admin\\\\model\\\\UserMoneyLog.php\": \"app\\\\admin\\\\model\\\\UserMoneyLog.php\",\r\n        \"app\\\\admin\\\\model\\\\UserRule.php\": \"app\\\\admin\\\\model\\\\UserRule.php\",\r\n        \"app\\\\admin\\\\model\\\\UserScoreLog.php\": \"app\\\\admin\\\\model\\\\UserScoreLog.php\",\r\n        \"app\\\\common\\\\model\\\\Attachment.php\": \"app\\\\common\\\\model\\\\Attachment.php\",\r\n        \"app\\\\common\\\\model\\\\Config.php\": \"app\\\\common\\\\model\\\\Config.php\",\r\n        \"app\\\\common\\\\model\\\\User.php\": \"app\\\\common\\\\model\\\\User.php\",\r\n        \"app\\\\common\\\\model\\\\UserMoneyLog.php\": \"app\\\\common\\\\model\\\\UserMoneyLog.php\",\r\n        \"app\\\\common\\\\model\\\\UserScoreLog.php\": \"app\\\\common\\\\model\\\\UserScoreLog.php\"\r\n    },\r\n    \"webViewsDir\": \"web\\\\src\\\\views\\\\backend\\\\auth\\\\admin\"\r\n}";
        return JsonConvert.DeserializeObject<dynamic>(str);

    }
}
